Set up the Template
The app you will use as a template is in the dev-base-build GitHub repo. It implements basic functionality, such as user authentication, and can be used as a starter kit.
Create a project
First you need to create a project for your simulation.
Follow these steps:
- Log in to Epicenter.
- On your organization's home page, create a new project.
- Create a workshop.
- Add users to the workshop.
It is a good practice to add at least one participant user and one facilitator user.
Clone the template
Download the application files on your development machine:
- Clone the https://github.com/forio/dev-base-build repository.
- In the local folder, run:
git fetch --allto download all branchesgit checkout exampleto switch to the Bicycle Sales example branch.
- To install the dependencies, run
npm install.
Finish set-up
- Edit the variable values in your application's
.envfile:VITE_PROJECT_NAME- this can be displayed in your application's UI.VITE_DEV_ACCOUNT_SHORT_NAME- this value must match the account short name on the Epicenter dashboard.VITE_DEV_PROJECT_SHORT_NAME- this should match the project short name in the Epicenter dashboard.VITE_DEV_API_HOST- the URL of the API server where your application will make requests.
- Upload the model and the
.ctx2file from the application's/modeldirectory to Epicenter:- Open the project in the dashboard.
- Click Project Files.
- On the Model tab, update the files.
The VITE_DEV variables in the .env file are required only for your app's local instance. Once you deploy the application interface to Epicenter, the values will be inferred from the project's URL.
You must upload the model files to Epicenter, even when running the application UI on your machine.
Run the application
Local instance
To start the app in development mode:
- In command line, go to your local
dev-base-buildfolder. - Run
npm run dev.
The application runs on http://localhost:8888/.
Deploy to Epicenter
To run your application on Epicenter:
- In command line, go to your local
dev-base-buildfolder. - Run
npm run build. - Open your project in the Epicenter dashboard.
- Click Project Files.
- On the Interface tab:
- Delete all existing files.
- Upload the contents of your application's
/publicfolder.
- In the dashboard, click Run Project.
Application files
This is a brief overview of some of the components of the template application.
- The
/src/main.tsxfile defines how requests are routed to the different parts of the application.RequireFocusedAuthchecks that the user is authenticated.PlayerShellis loaded for a participant.FacilitatorShellis loaded when a facilitator logs in to the application.PlayerHomedefines the elements on the participant's page in the sim. It gets variables from aRunQuery.
- Files in
/src/querydirectory contain wrappers around the JS library adapters.- In
run.ts,queryOptionsdefines how to fetch the data for the sim and how to cache it locally.queryFnfetches the data. - In
auth.ts,useLogin()calls theauthAdapter.login()function.
- In
- The
/src/routsdirectory contains components that handle various use cases. For example,/src/routs/login/handles login and password reset.